package com.mdd.admin.controller.course;

import com.mdd.admin.config.aop.Log;
import com.mdd.admin.service.course.ICourseMaterialService;
import com.mdd.admin.validate.course.CourseMaterialParam;
import com.mdd.admin.validate.common.PageParam;
import com.mdd.admin.vo.course.CourseMaterialListVo;
import com.mdd.admin.vo.course.CourseMaterialDetailVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 课件资料管理
 * @author panweiliang
 */
@RestController
@RequestMapping("api/course/material")
public class CourseMaterialController {

    @Resource
    ICourseMaterialService iCourseMaterialService;

    /**
     * 课件资料详情
     *
     * @author panweiliang
     * @param id 主键ID
     * @return Object
     */
    @GetMapping("/detail")
    public Object detail(@Validated @IDMust() @RequestParam("courseId") Integer courseId) {
        CourseMaterialDetailVo detail = iCourseMaterialService.detail(courseId);
        return AjaxResult.success(detail);
    }

    /**
     * 课件资料新增或编辑
     *
     * @author panweiliang
     * @param courseMaterialParam 参数
     * @return Object
     */
    @Log(title = "课件资料新增")
    @PostMapping("/addOrUpdate")
    public Object addOrUpdate(@Validated(value = CourseMaterialParam.create.class) @RequestBody CourseMaterialParam courseMaterialParam) {
        iCourseMaterialService.addOrUpdate(courseMaterialParam);
        return AjaxResult.success();
    }

    /**
     * 课件资料编辑
     *
     * @author panweiliang
     * @param courseMaterialParam 参数
     * @return Object
     */
//    @Log(title = "课件资料编辑")
//    @PostMapping("/edit")
//    public Object edit(@Validated(value = CourseMaterialParam.update.class) @RequestBody CourseMaterialParam courseMaterialParam) {
//        iCourseMaterialService.edit(courseMaterialParam);
//        return AjaxResult.success();
//    }

    /**
     * 课件资料删除
     *
     * @author panweiliang
     * @param courseMaterialParam 参数
     * @return Object
     */
//    @Log(title = "课件资料删除")
//    @PostMapping("/del")
//    public Object del(@Validated(value = CourseMaterialParam.delete.class) @RequestBody CourseMaterialParam courseMaterialParam) {
//        iCourseMaterialService.del(courseMaterialParam.getId());
//        return AjaxResult.success();
//    }

}
